/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.qframe.client.quicklet.beans;

import com.google.gwt.user.client.ui.HTMLPanel;
import org.qframe.client.gwtcustom.QuickletHTMLPanel;

/**
 *
 * @author gprasad
 */
public class RenderedQuicklet extends Quicklet {

    private QuickletHTMLPanel htmlPanel;
    private RenderedSlot containerSlot;

    public RenderedQuicklet(String quickletId, QuickletHTMLPanel htmlPanel, RenderedSlot containerSlot) {
        super(quickletId);
        this.htmlPanel = htmlPanel;
        this.containerSlot = containerSlot;
    }

    public RenderedQuicklet(Quicklet quicklet, QuickletHTMLPanel htmlPanel, RenderedSlot containerSlot) {
        super(quicklet.getQuickletId());
        this.htmlPanel = htmlPanel;
        this.containerSlot = containerSlot;
    }

    /**
     * Returns the QuickletHTMLPanel that this quicklet instance of rendered in.
     *
     * @return QuickletHTMLPanel
     */
    public QuickletHTMLPanel getHtmlPanel() {
        return htmlPanel;
    }

    /**
     * Returns the containing Slot.
     *
     * @return Slot
     */
    public RenderedSlot getContainerSlot() {

        return containerSlot;
    }

    /**
     * Returns the Quicklet containing this quicklet.
     *
     * @return Quicklet parentQuicklet
     */
    public RenderedQuicklet getParentQuicklet() {

        return containerSlot == null
                ? null
                : containerSlot.getParentQuicklet();
    }

    /**
     *
     * Set's the quicklet's continerSlot.
     *
     * @param containerSlot
     */
    void setContainerSlot(RenderedSlot containerSlot) {

        this.containerSlot = containerSlot;
    }

    @Override
    public String toString() {
        return "RenderedQuicklet:" + getQuickletId();
    }
}
